﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_User_ViewUser : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
        {
            
            BindAuthorityList();
            string UserID = "0";
            if (Request.QueryString["UserID"] != "" && Request.QueryString["UserID"] != null)
                UserID = Request.QueryString["UserID"];
            BinData(UserID);
        }
    }
    private void BindAuthorityList()
    {
        clsWebShop cls = new clsWebShop();
        ListItem item = new ListItem();
        ddlChuDe.DataSource = cls.Get_shr_AuthorityNoneProc().Tables[0];
        ddlChuDe.DataTextField = "AutNm";
        ddlChuDe.DataValueField = "AutID";
        ddlChuDe.DataBind();
        item.Text = "-- Chọn quyền hạn --";
        item.Value = "0";
        ddlChuDe.Items.Insert(0, item);

        if (Request.QueryString["AutID"] != "" && Request.QueryString["AutID"] != null)
            ddlChuDe.Items.FindByValue(Request.QueryString["AutID"]).Selected = true;
    }


    private void BinData(string UserID)
    {
        string AutID="";


        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("CusNm", txtName.Text.Trim());
        msg.CreateFirstNode("UserNm", txtLogin.Text.Trim());
        msg.CreateFirstNode("Email", txtEmail.Text.Trim());
        msg.CreateFirstNode("UserID", UserID);
        msg.CreateFirstNode("AutID", ddlChuDe.SelectedValue);
        clsWebShop cls = new clsWebShop();
        DataSet ds = null;
        ds = cls.Get_shr_UserCondition(msg.GetXmlStr);
        grv_Master.DataSource = ds;
        grv_Master.DataBind();

    }

    protected void ddlChuDe_SelectedIndexChanged(object sender, EventArgs e)
    {
        BinData("0");
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BinData("0");
    }
    protected void grv_Master_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grv_Master.PageIndex = e.NewPageIndex;
        BinData("0");
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {

    }
}